package com.example.dryyzx.dao;

import com.example.dryyzx.entity.CustomerDiet;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface CustomerDietMapper {
    @Delete({
        "delete from customer_diet",
        "where customer_id = #{customerId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer customerId);

    @Insert({
        "insert into customer_diet (customer_id, loving, ",
        "disease, suggest)",
        "values (#{customerId,jdbcType=INTEGER}, #{loving,jdbcType=VARCHAR}, ",
        "#{disease,jdbcType=VARCHAR}, #{suggest,jdbcType=VARCHAR})"
    })
    int insert(CustomerDiet record);

    @InsertProvider(type=CustomerDietSqlProvider.class, method="insertSelective")
    int insertSelective(CustomerDiet record);

    @Select({
        "select",
        "customer_id, loving, disease, suggest",
        "from customer_diet",
        "where customer_id = #{customerId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="customer_id", property="customerId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="loving", property="loving", jdbcType=JdbcType.VARCHAR),
        @Result(column="disease", property="disease", jdbcType=JdbcType.VARCHAR),
        @Result(column="suggest", property="suggest", jdbcType=JdbcType.VARCHAR)
    })
    CustomerDiet selectByPrimaryKey(Integer customerId);

    @UpdateProvider(type=CustomerDietSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(CustomerDiet record);

    @Update({
        "update customer_diet",
        "set loving = #{loving,jdbcType=VARCHAR},",
          "disease = #{disease,jdbcType=VARCHAR},",
          "suggest = #{suggest,jdbcType=VARCHAR}",
        "where customer_id = #{customerId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(CustomerDiet record);
}